<%@LANGUAGE="VBSCRIPT"%>
 
<!--#include file="functions.asp" -->
<%
'set cn=Server.CreateObject("ADODB.Connection")
'cn.Open "MP2ENTTEST2", "MP2", "MP2"
dim sql

'update exireg
'  	sql = "UPDATE EXILVOHEADER SET "
'	sql = sql & " ISOPEN='Y'" 
'	sql = sql & " WHERE LVONUM='" & request.querystring("LVOnum") &"'"

'	cn.execute(sql)
'cn.Close
%>


<%
set CompCode = Server.CreateObject("ADODB.Recordset")
CompCode.ActiveConnection = cn
CompCode.Source = "SELECT *  FROM dbo.COMPCODE"
'CompCode.CursorType = 0
'CompCode.CursorLocation = 2
'CompCode.LockType = 3
CompCode.Open()
CompCode_numRows = 0
%>
<%
Dim EXIREG__tmpNum
EXIREG__tmpNum = "''"
if (Request.QueryString("LVONum")  <> "") then EXIREG__tmpNum = Request.QueryString("LVONum") 
%>
<%
set EXIREG = Server.CreateObject("ADODB.Recordset")
EXIREG.ActiveConnection = cn
EXIREG.Source = "SELECT LVONUM, REGNUM, INVNUM, CREATEDBY, REQUESTEDBY, UCCODE,STATUS, VENDORID, INVDATE, (DATEADD(DAY,3,INVDATE)) AS INVDUEDATE,ORDERDATE,DUEDATE, INVRECBY,DEPT, MP2CURRENCY, SYMBOL, COMPCODE, VATNUM, WHTNAME, VATRATE, SUBTOTAL,WHTRATE, WHTAMOUNT, VATPAIDTOVENDOR,   (SELECT TOP 1 VENDOR.NAME  FROM VENDOR  WHERE VENDOR.VENDORID=EXILVOHEADER.VENDORID) AS VENDORNAME, (SELECT EMP.FIRSTNAME + ' '  + EMP.LASTNAME FROM dbo.EMP WHERE EMP.EMPCODE=EXILVOHEADER.INVRECBY) AS EMPNAME, INVVER, (SELECT EMP.FIRSTNAME + ' '  + EMP.LASTNAME FROM dbo.EMP WHERE EMP.EMPCODE=EXILVOHEADER.INVVER) AS VERNAME,INVAPPR,(SELECT EMP.FIRSTNAME + ' '  + EMP.LASTNAME FROM dbo.EMP WHERE EMP.EMPCODE=EXILVOHEADER.INVAPPR) AS APPRNAME,INVVERDATE,INVAPPRDATE,ROUTEUSER,REFERENCEDOC, COMMENTS  FROM dbo.EXILVOHEADER  WHERE LVONUM='" + Replace(EXIREG__tmpNum, "'", "''") + "'"
'EXIREG.CursorType = 0
'EXIREG.CursorLocation = 2
'EXIREG.LockType = 3
EXIREG.Open()
EXIREG_numRows = 0
%>
<%
Dim LVODET__tmpNum
LVODET__tmpNum = "''"
if (Request.QueryString("LVONum") <> "") then LVODET__tmpNum = Request.QueryString("LVONum")
%>
<%
set LVODET = Server.CreateObject("ADODB.Recordset")
LVODET.ActiveConnection = cn
LVODET.Source = "SELECT SEQNUM,DESCRIPTION, QTYREQUESTED, UOP, UNITCOST, TOTAL, LINENUMBER, COSTCENTER, ACCTCODE, ACTCODE, TAXCODE, DEPTEMPCODE  FROM dbo.EXILVOREQ  WHERE LVONUM='" + Replace(LVODET__tmpNum, "'", "''") + "'  ORDER BY LINENUMBER"
'LVODET.CursorType = 0
'LVODET.CursorLocation = 2
'LVODET.LockType = 3
LVODET.Open()
LVODET_numRows = 0
%>
<%
Dim Repeat1__numRows
Repeat1__numRows = -1
Dim Repeat1__index
Repeat1__index = 0
LVODET_numRows = LVODET_numRows + Repeat1__numRows
%>
<%
dim btnCaption
dim TrType
btnCaption=" Route Invoice "
trType="Route"

if (empCode=EXIREG.Fields.Item("INVVER").Value) then
btnCaption=" Verify Invoice "
trType="Verify"
end if

if (empCode=EXIREG.Fields.Item("INVAPPR").Value) then
btnCaption=" Approve Invoice "
trType="Approve"
end if
%>
<SCRIPT Language="JavaScript">
function DocLoad(){

}
function formSubmit(which) { 
var pass=true;
var status=document.form1.status.value;
var isUC='<%= isUC %>';
if ((status=="REJECTED")&&(isUC=="N")){
 alert("Cannot edit REJECTED invoice!");
 return false;
}
else
{
if (document.images) {
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name.substring(0,3)=="req") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
break;
         }
      }
   }
}
if (!pass) {
shortFieldName=tempobj.name.substring(3,30).toUpperCase();
alert("Please make sure the " + shortFieldName + " field was properly completed.");
return false;
}
else
  {
  
  if (document.form1.hf.value == "a"){ 
  document.form1.action= "Route_LVO.asp"; 
  } 
  if (document.form1.hf.value == "b")   { 
  document.form1.action= "Reject_LVO.asp"; 
  } 
  return true;
  }
}
} 


</SCRIPT>
<!-- #include file="pagetop_usr.asp" -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td nowrap height="21" bgcolor="#FFFFFF" width="3%" background="images/menu_end.gif">&nbsp;</td>
    <td nowrap height="21" bgcolor="#FFFFFF" width="28"> 
      <div align="center"><img src="images/menu_awal_off.gif" width="28" height="33"></div>
    </td>
    <td width="15%" background="images/menuoff.gif" height="21" nowrap> 
      <div align="center"><b><a href="My_invoice.asp" class="menu">My Invoice</a></b></div>
    </td>
    <td nowrap height="21" width="28"><img src="images/menu_off_off_separator.gif" width="28" height="33"></td>
    <td nowrap height="21" width="15%" background="images/menuoff.gif"> 
      <div align="center"><a href="My_invLVO_List.asp?InvStatus=0&RefOrder=0&CurSymbol=N" class="menu">My 
        Invoice Archive </a></div>
    </td>
    <td nowrap height="21" width="28"><img src="images/menu_off_on_separator.gif" width="28" height="33"></td>
    <td width="15%" background="images/menuon.gif" height="21" nowrap> 
      <div align="center"><b class="menu">Invoice Detail</b></div>
    </td>
    <td height="21" bgcolor="#FFFFFF" width="11"><img src="images/Menu_onend.gif" width="13" height="33"></td>
    <td height="21" bgcolor="#FFFFFF" background="images/menu_end.gif"> 
      <div align="right"><b><font color="#003399">Invoice From LVO</font></b> 
      </div>
    </td>
  </tr>
  <tr> 
    <td height="21" width="3%" bgcolor="#93bee2">&nbsp;</td>
    <td height="21" width="28" bgcolor="#93bee2">&nbsp;</td>
    <td width="10%" height="21" bgcolor="#93bee2">&nbsp;</td>
    <td height="21" width="28" bgcolor="#93bee2">&nbsp;</td>
    <td height="21" width="15%" bgcolor="#93bee2">&nbsp;</td>
    <td height="21" width="28" bgcolor="#93bee2">&nbsp;</td>
    <td width="10%" height="21" bgcolor="#93bee2">&nbsp;</td>
    <td height="21" bgcolor="#93bee2">&nbsp;</td>
    <td height="21" bgcolor="#93bee2">&nbsp;</td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#93bee2">
  <tr> 
    <td width="4%">&nbsp;</td>
    <td width="2%">&nbsp;</td>
    <td>&nbsp; </td>
  </tr>
  <tr> 
    <td width="4%">&nbsp;</td>
    <td width="2%">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr> 
    <td width="4%">&nbsp;</td>
    <td width="2%" bgcolor="#FFFFFF"><img src="images/curv_data.gif" width="21" height="21"></td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
  </tr>
  <tr> 
    <td width="4%">&nbsp;</td>
    <td width="2%" bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF"> 
      <form name="form1" method="post" action="Route_LVO.asp" onSubmit="return formSubmit(this);">
        <table width="100%" border="0" cellspacing="2" cellpadding="3">
          <tr> 
            <td width="15%" bgcolor="#dedede" height="25"> 
              <div align="right"><b> 
                <input type="hidden" name="MyInvoice" value="Y">
                <input type="hidden" name="seqnum2" value="<%=(EXIREG.Fields.Item("LVONUM").Value)%>">
                LVO No.:&nbsp;</b></div>
            </td>
            <td width="2%" height="25">&nbsp;</td>
            <td width="30%" valign="middle" height="25"> <b><%=(EXIREG.Fields.Item("LVONUM").Value)%></b> 
            </td>
            <td width="15%" bgcolor="#dedede" height="25"> 
              <div align="right"><b> 
                <input type="hidden" name="status" value="<%=(EXIREG.Fields.Item("STATUS").Value)%>">
                Status:&nbsp;</b></div>
            </td>
            <td width="2%" height="25">&nbsp;</td>
            <td height="25"><b><font color="#880000"><%=(EXIREG.Fields.Item("STATUS").Value)%></font></b></td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede" height="25"> 
              <div align="right"><b>Invoice No.:&nbsp;</b></div>
            </td>
            <td width="2%" height="25">&nbsp;</td>
            <td width="30%" height="25"><%=(EXIREG.Fields.Item("INVNUM").Value)%> 
            </td>
            <td width="15%" bgcolor="#dedede" height="25"> 
              <div align="right"><b>Order Date:&nbsp;</b></div>
            </td>
            <td width="2%" height="25">&nbsp;</td>
            <td height="25"><%= DoDateTime((EXIREG.Fields.Item("ORDERDATE").Value), 1, 2057) %> 
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede" height="25"> 
              <div align="right"><b>Inv. Received Date:&nbsp;</b></div>
            </td>
            <td width="2%" height="25">&nbsp;</td>
            <td width="30%" height="25"> <%= DoDateTime((EXIREG.Fields.Item("INVDATE").Value), 1, 2057) %> 
            </td>
            <td width="15%" bgcolor="#dedede" height="25"> 
              <div align="right"><b>Inv. Due Date:&nbsp;</b></div>
            </td>
            <td width="2%" height="25">&nbsp;</td>
            <td height="25"><%= DoDateTime((EXIREG.Fields.Item("INVDUEDATE").Value), 1, 2057) %> 
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede" height="25"> 
              <div align="right"><b>Vendor Name:&nbsp;</b></div>
            </td>
            <td width="2%" height="25">&nbsp;</td>
            <td width="30%" height="25"><%=(EXIREG.Fields.Item("VENDORNAME").Value)%> 
            </td>
            <td width="15%" bgcolor="#dedede" height="25"> 
              <div align="right"><b>Created By:&nbsp;&nbsp;</b></div>
            </td>
            <td width="2%" height="25">&nbsp;</td>
            <td bgcolor="#FFFFFF" height="25"> <%=(EXIREG.Fields.Item("CREATEDBY").Value)%>&nbsp 
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede" height="25"> 
              <div align="right"><b>Invoice Amount:&nbsp;</b></div>
            </td>
            <td width="2%" height="25">&nbsp;</td>
            <td height="25"><b><%=(EXIREG.Fields.Item("SYMBOL").Value)%>&nbsp;&nbsp; 
              <%=(FormatNumber((EXIREG.Fields.Item("SUBTOTAL").Value), -1, -2, -2, -1))%> 
              </b></td>
            <td bgcolor="#dedede" height="25"> 
              <div align="right"><b>Requested By:&nbsp;</b></div>
            </td>
            <td height="25">&nbsp;</td>
            <td height="25"><%=(EXIREG.Fields.Item("REQUESTEDBY").Value)%></td>
          </tr>
          <tr> 
            <td width="15%" height="25"> 
              <div align="right"></div>
            </td>
            <td width="2%" height="25">&nbsp;</td>
            <td width="30%" height="25"> 
              <input type="hidden" name="VendorName" value="<%=(EXIREG.Fields.Item("VENDORNAME").Value)%>">
              <input type="hidden" name="InvoiceNo" value="<%=(EXIREG.Fields.Item("INVNUM").Value)%>">
            </td>
            <td width="15%" bgcolor="#dedede" height="25"> 
              <div align="right"><b>Department:&nbsp;</b></div>
            </td>
            <td width="2%" height="25">&nbsp;</td>
            <td height="25"><%=(EXIREG.Fields.Item("DEPT").Value)%></td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede" height="25"> 
              <div align="right"><b>Original Invoice:&nbsp;</b></div>
            </td>
            <td width="2%" height="25">&nbsp;</td>
            <td colspan="4" height="25"><a href="javascript:opennew('<%=(EXIREG.Fields.Item("REFERENCEDOC").Value)%>')"><%=(EXIREG.Fields.Item("REFERENCEDOC").Value)%></a></td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#FFFFFF">&nbsp;</td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <input type="button" name="Submit2" value=" View Invoice " class="sbttn" onClick="opennew('<%=(EXIREG.Fields.Item("REFERENCEDOC").Value)%>')">
              <b> 
              <script language="JavaScript">
function checkVerName()
{ if (document.form1.reqEndUser.value == '<%= empCode %>')
   { document.form1.btnRoute.value = ' Verify Invoice ';
     document.form1.TrType.value = 'Verify';
   }
   else
   { document.form1.btnRoute.value = ' Route Invoice ';
     document.form1.TrType.value = 'Route'; } 
}
</script>
              </b> </td>
            <td width="15%" bgcolor="#FFFFFF">&nbsp;</td>
            <td width="2%">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Verify By:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td colspan="4"> <%=(EXIREG.Fields.Item("INVVER").Value)%> &nbsp;&nbsp; 
              <%=(EXIREG.Fields.Item("VERNAME").Value)%> &nbsp;&nbsp;&nbsp; 
              <% if (EXIREG.Fields.Item("INVVERDATE").Value<>"") then %>
              <img src="images/check.jpg" width="18" height="17">&nbsp;Verified &nbsp;&nbsp;<%=EXIREG.Fields.Item("INVVERDATE").Value %>
              <% end if %>
              <input type="hidden" name="Dept" size="15" class="InputBox" value="<%=(EXIREG.Fields.Item("DEPT").Value)%>">
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Authorised By:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td colspan="4"> <%=(EXIREG.Fields.Item("INVAPPR").Value)%> &nbsp;&nbsp; 
              <%=(EXIREG.Fields.Item("APPRNAME").Value)%> 
              <% if isdate(EXIREG.Fields.Item("INVAPPRDATE").Value) then %>
              &nbsp;&nbsp;&nbsp;<img src="images/check.jpg" width="18" height="17">&nbsp;Approved&nbsp;&nbsp;<%=EXIREG.Fields.Item("INVAPPRDATE").Value %> 
              <% end if %>
              <input type="hidden" name="Dept2">
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#FFFFFF"> 
              <div align="right"><b></b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="30%">&nbsp;</td>
            <td width="15%" bgcolor="#FFFFFF"> 
              <input type="hidden" name="TrType" value="<%= TrType %>">
              <input type="hidden" name="UC" value="<%=(EXIREG.Fields.Item("UCCODE").Value)%>">
              <input type="hidden" name="recBy" value="<%=(EXIREG.Fields.Item("INVRECBY").Value)%>">
            </td>
            <td width="2%">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Comments:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td colspan="4"> <%=(EXIREG.Fields.Item("COMMENTS").Value)%> </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#FFFFFF" height="20">&nbsp;</td>
            <td width="2%" height="20">&nbsp;</td>
            <td width="30%" height="20">&nbsp;</td>
            <td width="15%" bgcolor="#FFFFFF" height="20">&nbsp;</td>
            <td width="2%" height="20">&nbsp;</td>
            <td height="20">&nbsp;</td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Action:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td colspan="4"> 
              <input type="submit" name="Submit4" value=" Close " class="sbttn" onClick="window.location='My_invLVO_List.asp';">
              <input type="hidden" name="hf" value="a">
            </td>
          </tr>
        </table>
      </form>
    </td>
  </tr>
  <tr> 
    <td width="4%">&nbsp;</td>
    <td width="2%" bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#bbbbbb">
  <tr bgcolor="#D1DDEF"> 
    <td width="4%" height="26"> 
      <div align="center"><font color="#000000"><b>No</b></font></div>
    </td>
    <td height="26"> 
      <div align="center"><font color="#000000"><b>Description</b></font></div>
    </td>
    <td width="5%" height="26"> 
      <div align="center"><font color="#000000"><b>Qty</b></font></div>
    </td>
    <td width="5%" height="26"> 
      <div align="center"><font color="#000000"><b>UoP</b></font></div>
    </td>
    <td width="8%" height="26"> 
      <div align="center"><font color="#000000"><b>Unit Cost</b></font></div>
    </td>
    <td width="8%" height="26"> 
      <div align="center"><font color="#000000"><b>Total</b></font></div>
    </td>
    <td height="26" width="10%"> 
      <div align="center"><b><b>Charge Code</b></b></div>
    </td>
    <td height="26" width="8%"> 
      <div align="center"><b><b>AFE</b></b></div>
    </td>
    <td height="26" width="6%"> 
      <div align="center"><b><b>Activity</b></b></div>
    </td>
    <td height="26" width="8%"> 
      <div align="center"><b>T3 Code</b></div>
    </td>
    <td height="26" width="5%"> 
      <div align="center"><b><font color="#FFFFFF"><font color="#000000"><b><b>Tax</b></b></font></font></b></div>
    </td>
  </tr>
  <% 
While ((Repeat1__numRows <> 0) AND (NOT LVODET.EOF)) 
%>
  <tr bgcolor="#FFFFFF" valign="top"> 
    <td width="4%"> 
      <div align="right"><%=(LVODET.Fields.Item("LINENUMBER").Value)%>.&nbsp;</div>
    </td>
    <td> 
      <input type="hidden" name="seqnum<%=(LVODET.Fields.Item("LINENUMBER").Value)%>" value="<%=(LVODET.Fields.Item("SEQNUM").Value)%>">
      <%=(LVODET.Fields.Item("DESCRIPTION").Value)%></td>
    <td width="5%"> 
      <div align="right"><%=(LVODET.Fields.Item("QTYREQUESTED").Value)%></div>
    </td>
    <td width="5%"> 
      <div align="center"><%=(LVODET.Fields.Item("UOP").Value)%></div>
    </td>
    <td width="8%"> 
      <div align="right"><%= FormatNumber((LVODET.Fields.Item("UNITCOST").Value), -1, -2, -2, -1) %></div>
    </td>
    <td width="8%"> 
      <div align="right"><%= FormatNumber((LVODET.Fields.Item("TOTAL").Value), -1, -2, -2, -1) %></div>
    </td>
    <td width="10%"> 
      <div align="center"> <%=(LVODET.Fields.Item("ACCTCODE").Value)%> </div>
    </td>
    <td width="8%"> 
      <div align="center"> <%=(LVODET.Fields.Item("COSTCENTER").Value)%> </div>
    </td>
    <td width="6%"> 
      <div align="center"> <%=(LVODET.Fields.Item("ACTCODE").Value)%> </div>
    </td>
    <td width="8%"> 
      <div align="center"> <%=(LVODET.Fields.Item("DEPTEMPCODE").Value)%> </div>
    </td>
    <td width="5%"> 
      <div align="center"><%=(LVODET.Fields.Item("TAXCODE").Value)%></div>
    </td>
  </tr>
  <% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  LVODET.MoveNext()
Wend
%>
  <tr bgcolor="#FFFFFF"> 
    <td width="4%"> 
      <div align="right"></div>
    </td>
    <td> 
      <div align="center"> </div>
    </td>
    <td width="5%">&nbsp;</td>
    <td width="5%">&nbsp;</td>
    <td width="8%"> 
      <div align="right"></div>
    </td>
    <td width="8%"> 
      <div align="right"></div>
    </td>
    <td width="10%">&nbsp;</td>
    <td width="8%">&nbsp;</td>
    <td width="6%">&nbsp;</td>
    <td width="8%">&nbsp;</td>
    <td width="5%">&nbsp;</td>
  </tr>
</table>
</body>
</html>
<%
CompCode.Close()
%>
<%
EXIREG.Close()
%>
<%
LVODET.Close()
%>
